/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojos;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author A7med Kotb
 */
@Entity
@Table(name = "projects")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Projects.findAll", query = "SELECT p FROM Projects p"),
    @NamedQuery(name = "Projects.findByProId", query = "SELECT p FROM Projects p WHERE p.proId = :proId"),
    @NamedQuery(name = "Projects.findByProjectCode", query = "SELECT p FROM Projects p WHERE p.projectCode = :projectCode"),
    @NamedQuery(name = "Projects.findByProjectName", query = "SELECT p FROM Projects p WHERE p.projectName like :projectName"),
    @NamedQuery(name = "Projects.findByActivityCode", query = "SELECT p FROM Projects p WHERE p.activityCode = :activityCode"),
    @NamedQuery(name = "Projects.findByCreatedAt", query = "SELECT p FROM Projects p WHERE p.createdAt = :createdAt"),
    @NamedQuery(name = "Projects.findByStatus", query = "SELECT p FROM Projects p WHERE p.status = :status")})
public class Projects implements Serializable {
    @Column(name = "created_at")
    private String createdAt;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
   
    @Column(name = "pro_id")
    private Integer proId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "project_code")
    private String projectCode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "project_name")
    private String projectName;
    @Size(max = 45)
    @Column(name = "activity_code")
    private String activityCode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "status")
    private String status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "projectCode")
    private Collection<SourceCode> sourceCodeCollection;
    @JoinColumn(name = "customer", referencedColumnName = "cust_id")
    @ManyToOne(optional = false)
    private Customers customer;
    @JoinColumn(name = "created_by", referencedColumnName = "emp_id")
    @ManyToOne(optional = false)
    private Employees createdBy;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private Collection<TimeLog> timeLogCollection;
    @OneToMany(mappedBy = "project")
    private Collection<Expenses> expensesCollection;

    public Projects() {
    }

    public Projects(Integer proId) {
        this.proId = proId;
    }

    public Projects(Integer proId, String projectCode, String projectName, String createdAt, String status) {
        this.proId = proId;
        this.projectCode = projectCode;
        this.projectName = projectName;
        this.createdAt = createdAt;
        this.status = status;
    }

    public Integer getProId() {
        return proId;
    }

    public void setProId(Integer proId) {
        this.proId = proId;
    }

    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getActivityCode() {
        return activityCode;
    }

    public void setActivityCode(String activityCode) {
        this.activityCode = activityCode;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @XmlTransient
    public Collection<SourceCode> getSourceCodeCollection() {
        return sourceCodeCollection;
    }

    public void setSourceCodeCollection(Collection<SourceCode> sourceCodeCollection) {
        this.sourceCodeCollection = sourceCodeCollection;
    }

    public Customers getCustomer() {
        return customer;
    }

    public void setCustomer(Customers customer) {
        this.customer = customer;
    }

    public Employees getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Employees createdBy) {
        this.createdBy = createdBy;
    }

    @XmlTransient
    public Collection<TimeLog> getTimeLogCollection() {
        return timeLogCollection;
    }

    public void setTimeLogCollection(Collection<TimeLog> timeLogCollection) {
        this.timeLogCollection = timeLogCollection;
    }

    @XmlTransient
    public Collection<Expenses> getExpensesCollection() {
        return expensesCollection;
    }

    public void setExpensesCollection(Collection<Expenses> expensesCollection) {
        this.expensesCollection = expensesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (proId != null ? proId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Projects)) {
            return false;
        }
        Projects other = (Projects) object;
        if ((this.proId == null && other.proId != null) || (this.proId != null && !this.proId.equals(other.proId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojos.Projects[ proId=" + proId + " ]";
    }
}
